package o;

import android.content.Context;
import android.os.Handler;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.view.ViewGroup.LayoutParams;
import android.widget.ImageView;
import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;
import androidx.recyclerview.widget.RecyclerView.a;
import androidx.recyclerview.widget.RecyclerView.s;
import com.huawei.appgallery.assistantdock.base.cardkit.bean.BuoyBaseCardBean;
import com.huawei.appgallery.assistantdock.gamemode.card.BuoyBaseEnterCard;
import java.util.ArrayList;
import java.util.Collections;

public class bir extends a implements bie {
    private boolean ˊ = false;
    private Context ˎ;
    private bij ˏ;
    private ArrayList ॱ;

    public static class d extends o.mi.d {
        private final bie ˎ;

        public d(bie o_bie) {
            this.ˎ = o_bie;
        }

        public int ˋ(@NonNull RecyclerView recyclerView, @NonNull s sVar) {
            if (this.ˎ == null || !this.ˎ.ॱ()) {
                return o.mi.d.ˋ(0, 0);
            }
            if (sVar instanceof e) {
                e eVar = (e) sVar;
                boolean ˊˋ = eVar.ˊˋ();
                Object ˊˊ = eVar.ˊˊ();
                if (ˊˋ || "all_service".equals(ˊˊ) || "all_app".equals(String.valueOf(ˊˊ))) {
                    return o.mi.d.ˋ(0, 0);
                }
            }
            return o.mi.d.ˋ(15, 0);
        }

        public boolean ˎ() {
            return true;
        }

        public boolean ˊ() {
            return false;
        }

        public boolean ˊ(@NonNull RecyclerView recyclerView, @NonNull s sVar, @NonNull s sVar2) {
            if (sVar.ॱॱ() != sVar2.ॱॱ()) {
                return false;
            }
            if (!(sVar2 instanceof e)) {
                return false;
            }
            e eVar = (e) sVar2;
            Object ˊˊ = eVar.ˊˊ();
            if (eVar.ˊˋ() || "all_service".equals(ˊˊ) || "all_app".equals(String.valueOf(ˊˊ))) {
                return false;
            }
            this.ˎ.ˎ(sVar.ˋ(), sVar2.ˋ());
            return true;
        }

        public void ˊ(@NonNull s sVar, int i) {
        }

        public void ॱ(s sVar, int i) {
            if (i != 0 && (sVar instanceof bik)) {
                ((bik) sVar).F_();
            }
            super.ॱ(sVar, i);
        }

        public void ˊ(@NonNull RecyclerView recyclerView, @NonNull s sVar) {
            super.ˊ(recyclerView, sVar);
            if (sVar instanceof bik) {
                ((bik) sVar).ॱ();
            }
        }
    }

    public static class e extends s implements bik, OnClickListener {
        private ImageView ʻॱ;
        private bij ʽॱ;
        private boolean ʿ;
        private View ॱˋ;
        private boolean ॱᐝ = true;
        private Object ᐝॱ;

        public e(View view, boolean z, bij o_bij) {
            super(view);
            this.ॱˋ = view;
            this.ʿ = z;
            this.ʽॱ = o_bij;
            this.ᐝॱ = null;
            this.ʻॱ = (ImageView) view.findViewById(beo$e.ॱʽ);
            this.ʻॱ.setOnClickListener(this);
        }

        public boolean ˋ(Object obj, boolean z, boolean z2) {
            this.ʿ = z;
            this.ᐝॱ = obj;
            this.ॱᐝ = z2;
            return ˉ();
        }

        private boolean ˉ() {
            ImageView imageView = (ImageView) this.ॱˋ.findViewById(beo$e.ͺॱ);
            if (this.ॱᐝ) {
                imageView.setBackgroundResource(beo$d.ͺॱ);
                this.ʻॱ.setVisibility(8);
                return true;
            }
            BuoyBaseEnterCard ˊ = new bid(this.ॱˋ.getContext()).ˊ(this.ᐝॱ, true, false, "ALLSERVICE");
            if (ˊ != null) {
                if (this.ᐝॱ instanceof biu.a) {
                    Object ˊ2 = ((biu.a) this.ᐝॱ).ˊ();
                } else {
                    String str = (String) this.ᐝॱ;
                }
                if (!this.ʿ || "all_service".equals(r0) || "all_app".equals(r0)) {
                    this.ʻॱ.setVisibility(8);
                } else {
                    this.ʻॱ.setVisibility(0);
                }
                ˊ.ˎ(this.ʿ);
                ˊ.ˏ(this.ॱˋ);
                ˊ.ˏ(new BuoyBaseCardBean());
                return true;
            }
            this.ʻॱ.setVisibility(8);
            return false;
        }

        public boolean ˊˋ() {
            return this.ॱᐝ;
        }

        public Object ˊˊ() {
            return this.ᐝॱ;
        }

        public void F_() {
            this.ॱˋ.setScaleX(1.1f);
            this.ॱˋ.setScaleY(1.1f);
        }

        public void ॱ() {
            this.ॱˋ.setScaleX(1.0f);
            this.ॱˋ.setScaleY(1.0f);
        }

        public void onClick(View view) {
            if (this.ʽॱ != null && this.ᐝॱ != null) {
                this.ʽॱ.ˏ(this.ᐝॱ);
            }
        }
    }

    public ArrayList ʼ() {
        return this.ॱ;
    }

    public bir(bij o_bij, ArrayList arrayList, Context context) {
        this.ॱ = arrayList;
        this.ˏ = o_bij;
        this.ˎ = context;
    }

    public void ˊ(ArrayList arrayList) {
        this.ॱ = arrayList;
    }

    public void ˊ(boolean z) {
        this.ˊ = z;
    }

    @NonNull
    public s ˎ(@NonNull ViewGroup viewGroup, int i) {
        View inflate = LayoutInflater.from(viewGroup.getContext()).inflate(beo$j.ʻ, viewGroup, false);
        LayoutParams layoutParams = inflate.getLayoutParams();
        layoutParams.width = -1;
        inflate.setLayoutParams(layoutParams);
        return new e(inflate, this.ˊ, this.ˏ);
    }

    public void ॱ(@NonNull s sVar, int i) {
        boolean z = false;
        if (sVar instanceof e) {
            sVar.ॱ(false);
            e eVar = (e) sVar;
            if (CollectCheck.isEmpty(this.ॱ) || i < 0 || i >= this.ॱ.size()) {
                z = true;
            }
            if (!eVar.ˋ(ʼ(i), this.ˊ, z)) {
                ॱॱ(i);
                if (ʼ(i) != null) {
                    ॱ(sVar, i);
                }
            }
        }
    }

    private Object ʼ(int i) {
        if (CollectCheck.isEmpty(this.ॱ) || i < 0 || i >= this.ॱ.size()) {
            return null;
        }
        return this.ॱ.get(i);
    }

    private void ॱॱ(final int i) {
        if (!CollectCheck.isEmpty(this.ॱ) && i >= 0 && i < this.ॱ.size() && this.ˏ != null && this.ॱ.get(i) != null) {
            if (this.ˎ != null) {
                new Handler(this.ˎ.getMainLooper()).post(new Runnable(this) {
                    final /* synthetic */ bir ˏ;

                    public void run() {
                        this.ˏ.ˏ.ˏ(Integer.valueOf(i));
                    }
                });
            }
            this.ॱ.remove(i);
        }
    }

    public int ˏ() {
        return 8;
    }

    public boolean ॱ() {
        return this.ˊ;
    }

    public void ˎ(int i, int i2) {
        int i3;
        if (i < i2) {
            for (i3 = i; i3 < i2; i3++) {
                Collections.swap(this.ॱ, i3, i3 + 1);
            }
        } else {
            for (i3 = i; i3 > i2; i3--) {
                Collections.swap(this.ॱ, i3, i3 - 1);
            }
        }
        ˋ(i, i2);
    }
}
